@lg: 24px;
@md: 22px;
@sm: 20px;
@xs: 18px;

@lg-min-width: 42px;
@md-min-width: 37px;
@sm-min-width: 32px;
@xs-min-width: 27px;

.set-size(@size, @min-width) {
  & {
    .layui-form-switch {
      height: @size;
      min-width: @min-width;
      span{
        width: calc(@size - 4px);
        height: calc(@size - 4px);
        transition:all 0.1s linear;
      }
      em{
        margin-left: calc(@size - 3px);
      }
    }
    .layui-form-onswitch{
      span{
        left: calc(100% - calc(@size - 1px));
      }
      em{
        margin-right: calc(@size - 3px);
        margin-left: 0px;
      }
    }
  }
}

.layui-switch-container{
  &[size="lg"] {
    .set-size(@lg,@lg-min-width);
  }
  &[size="md"] {
    .set-size(@md,@md-min-width);
  }
  &[size="sm"] {
    .set-size(@sm,@sm-min-width);
  }
  &[size="xs"] {
    .set-size(@xs,@xs-min-width);
  }
}

.layui-form-switch {
  position: relative;
  height: 22px;
  line-height: 22px;
  min-width: 35px;
  padding: 0 4px;
  border-radius: 20px;
  cursor: pointer;
  background-color: var(--global-neutral-color-6);
  -webkit-transition:all 0.1s linear;
  transition:all 0.1s linear;
}

.layui-form-switch span {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  left: 3px;
  top: 2px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  border-radius: 20px;
  background-color: #fff;
  box-shadow: 0 2px 4px #00230b33;
  -webkit-transition:all 0.1s linear;
  transition:all 0.1s linear;
}

.layui-form-switch em {
  position: relative;
  top: 0;
  width: 25px;
  padding: 0 !important;
  text-align: center !important;
  color: #999 !important;
  font-style: normal !important;
  font-size: 12px;
}

.layui-form-onswitch {
  border-color: var(--global-checked-color);
  background-color: var(--global-checked-color);
}

.layui-form-onswitch span {
  background-color: #fff;
}

.layui-form-onswitch em {
  color: #fff !important;
}

.layui-switch-disabled[lay-skin="primary"] span {
  background: 0 0 !important;
  color: var(--global-neutral-color-8) !important;
}

.layui-switch-disabled[lay-skin="primary"]:hover i {
  border-color: var(--global-neutral-color-6);
}

.layui-switch-disabled,
.layui-switch-disabled i {
  border-color: var(--global-neutral-color-3) !important;
}

.layui-switch-disabled span {
  background-color: var(--global-neutral-color-3) !important;
}

.layui-switch-disabled em {
  color: var(--global-neutral-color-6) !important;
}

.layui-switch-disabled:hover i {
  color: #fff !important;
}
